package com.online.pay.web.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.online.pay.common.utils.ValidationResult;
import com.online.pay.common.utils.ValidationUtils;
import com.online.pay.web.dao.entity.OrderInfo;
import com.online.pay.web.dao.mapper.OrderInfoMapper;
import com.online.pay.web.service.OrderInfoService;

@Service
public class OrderInfoSerivceImpl implements OrderInfoService{
	
	public static final Logger logger = LoggerFactory.getLogger(OrderInfoSerivceImpl.class);
	
	@Autowired
	private OrderInfoMapper orderInfoMapper;

	@Override
	public OrderInfo selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean save(OrderInfo orderInfo) {
		try {
			ValidationResult result = ValidationUtils.validateEntity(orderInfo);
			if (orderInfo == null && result.isHasErrors()) {
				logger.error("[]TradeOrderServiceImpl save validate error", result.getErrorMsg());
				return false;
			}
			orderInfoMapper.insert(orderInfo);
		} catch (Exception e) {
			 logger.error("[TradeOrderServiceImpl.save] error：", e);
	            return false;
		}
		return true;
	}

	@Override
	public int updateByPrimaryKeySelective(OrderInfo orderInfo) {
		try {
			ValidationResult result = ValidationUtils.validateEntity(orderInfo);
			if (orderInfo == null && result.isHasErrors()) {
				logger.error(" update validate error", result.getErrorMsg());
			}
		} catch (Exception e) {
			 logger.error("update error：", e);
		}
		return orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
	}



}
